<?php
session_start();
if(! isset($_SESSION['id'])) {
    header('Location:index.html');
}
?>
<?php 
if($_SESSION['id']!=='92'){
header('Location:index.html');
}
 ?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>账号管理系统</title>
    <link href="css/bootstrap.min.css" type="text/css" rel="stylesheet">
    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <style>
        .div{
            position: relative;
            text-align: center;
            padding-left: 500px;
        }
        .font{
            font-size: 16px;
            font-weight: bold;;
        }
        form{
            font-weight:bold;
        }
    </style>
</head>
<body style="text-align: center">
<?php include ('menu.php');
//1. 链接数据库
header("content-type:text/html;charset=utf8");
include('conn.php');
$id=$_GET['id'];
//2.执行sql
$sql_select = "select * from liu where id='$id'";
$stmt = mysqli_query($conn,$sql_select);
//    var_dump($stmt);
//    die();
$liu = mysqli_fetch_assoc($stmt); // 解析数据
?>
<h3>修改信息</h3>
<form   method="post" class="form-inline">

    <div class="form-group">
        
        <span class="font">游戏名:</span><input type="text" name="nicheng" class="form-control" value="<?php echo $liu['nicheng'];?>"><br><br>
        <span class="font">时间:</span><input type="text" name="ss" class="form-control"  value="<?php echo 
$time = date('Y-m-d  h:i:s', time());?>">
<br><br>
        <span class="font">内容:</span><textarea  name="nr" id="" class="form-control" cols="30" rows="10"value=""><?php echo $liu['nr'];?></textarea>
        </span>
<br><br>
        <span class="font">IP：</span><input type="text" name="ip" class="form-control" value="<?php echo $liu['ip']?>"><br><br>
       


      
        <a href="main.php" class="btn btn-success">返回</a>
        <input type="submit" value="确定" class="btn btn-primary">
        <input type="reset" value="重置" class="btn btn-warning">
    </div>


</form>
 
<?php
if($_SERVER["REQUEST_METHOD"]=="POST") {
include('conn.php');
      
	$nicheng=$_POST['nicheng'];
       $ss=$_POST['ss'];
       $nr=$_POST['nr'];
       $ip=$_POST['ip'];
$sql = "UPDATE `liu` SET `nicheng` = '$nicheng' ,
`ss` = '$ss',`nr` = '$nr',`ip` = '$ip' WHERE `id` = ".$liu['id'];
    
    $rw = mysqli_query($conn, $sql);
    if ($rw) {
   
    $_SESSION['nicheng'] = $nicheng; 
    $_SESSION['ss'] = $ss; 
    $_SESSION['nr'] = $nr; 
    $_SESSION['ip'] = $ip; 
 
      
   echo "<script>alert('修改成功');</script>";
    echo "<script>window.location.href='/main2.php'</script>";
    } else {
     echo "<script>alert('修改失败');</script>";
     

    }
}




?>
</body>
</html>